package com.hotacorp.opencloud.logservice.controller;

import java.util.Map;

import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import com.hotacorp.opencloud.common.commdata.LogBean;
import com.hotacorp.opencloud.common.commdata.Result;
import com.hotacorp.opencloud.common.mybatisplus.PageData;
import com.hotacorp.opencloud.logservice.entity.SysLogEntity;
import com.hotacorp.opencloud.logservice.service.SysLogService;

import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import springfox.documentation.annotations.ApiIgnore;

/**
 * 
 * 日志的插入、查询
 * @author lwg
 * @email liwugang@139.com
 * @date 2020-01-16 13:46:53
 */
@RestController
@Api(tags = "操作日志API")
public class SysLogController {
    @Autowired
    private SysLogService sysLogService;

    /**
     * 列表
     */
    @GetMapping(value = "/syslog/list")
    @PreAuthorize("hasAuthority('logservice:syslog:list')")
	@ApiOperation(value = "查询操作日志")
    public Result<?> list(@RequestParam Map<String, Object> params){
        PageData page = sysLogService.queryPage(params);

        return Result.succeed("succeed", page);
    }

    /**
     * 保存操作日志
     */
    @PostMapping("/anon/addOpeLog")
    @ApiIgnore
    public Result<?> saveOpe(@RequestBody LogBean sysLog){
    	SysLogEntity aaaEntity = new SysLogEntity();
    	BeanUtils.copyProperties(sysLog, aaaEntity);
		sysLogService.save(aaaEntity);

        return Result.succeed();
    }


}
